#include <QtTest/QTest>

#include "Reader.h"

library::Reader::Reader(Shelf *shelf, int time, QObject *parent) :
  shelf(shelf), time(time), QObject(parent) {}

void library::Reader::run() {

  while(true) {

    if(shelf->size() == 0) 
      continue;

    int pos = qrand() % shelf->size();

    emit wait();

    shelf->take(pos);

    emit read();

    QTest::qSleep(time*1000);

    shelf->put(pos);

  }

}
